//
//  FirestStartViewController.m
//  MyWorld
//
//  Created by 王金晶 on 16/3/28.
//  Copyrigh vvt © 2016年 王金晶. All rights reserved.
//

#import "FirestStartViewController.h"
#import "TabbarViewController.h"

@interface FirestStartViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollerView;
@property (weak, nonatomic) IBOutlet UIPageControl *page;

@end

@implementation FirestStartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.scrollerView.contentSize = CGSizeMake(Width * 3, Height);
    self.page.numberOfPages = 3;
    for (int i = 0; i< 3; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(Width * i, 0, Width, Height)];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d",i + 1]];
        if (i == 2) {
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake((Width - 150) / 2, Height - 150, 150, 30);
            [button setTitle:@"点此进入" forState:UIControlStateNormal];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(putInto:) forControlEvents:UIControlEventTouchUpInside];
            imageView.userInteractionEnabled = YES;
            [imageView addSubview:button];
        }
        [_scrollerView addSubview:imageView];
    }
    
    
    
    
    
}
#pragma mark ----------进入真正的根试图--------------
- (void)putInto:(UIButton *)button
{
    TabbarViewController *tabBarVc = [[TabbarViewController alloc]init];
    [self presentViewController:tabBarVc animated:YES completion:nil];
    
    
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    NSInteger index = scrollView.contentOffset.x / Width;
    self.page.currentPage = index;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
